﻿using System;
using System.Collections.Generic;
using System.Text;
using WarehouseWebAPP.code.DAL;
using WarehouseWebAPP.code.DAL.CustomerTypeDSTableAdapters;

namespace WarehouseWebAPP.code.BLL
{
    public class CustomerTypeBLL
    {
        private customer_type_tableTableAdapter CustomerTypeAdapter = null;
        public customer_type_tableTableAdapter Adapter
        {
            get
            {
                if (CustomerTypeAdapter == null) CustomerTypeAdapter = new customer_type_tableTableAdapter();
                return CustomerTypeAdapter;
            }
        }
        public CustomerTypeDS.customer_type_tableDataTable CustomerTypeGet()
        {
            return Adapter.GetData();
        }
        public CustomerTypeDS.customer_type_tableDataTable CustomerTypeGetByNum(Guid customer_type_num)
        {
            if (customer_type_num == null)
                throw new Exception("Customer Type Num is missing");
            return Adapter.CustomerTypeGetByNum(customer_type_num);
        }

        public void CustomerTypeInsert(string customer_type)
        {
            if (customer_type == null)
                throw new Exception("Customer Type is missing");
            Adapter.CustomerTypeInsert(customer_type);
        }

        public void CustomerTypeDelete(Guid customer_type_num)
        {
            if (customer_type_num == null)
                throw new Exception("Customer Type Number is missing");
            if (Adapter.CustomerTypeDelete(customer_type_num) < 1)
                throw new Exception("Customer Type was not Deleted");
        }

        public void CustomerTypeUpdate(Guid customer_type_num, string customer_type)
        {
            if (customer_type_num == null)
                throw new Exception("Customer Type Number is missimg");
            if (customer_type == null)
                throw new Exception("Customer Type is missing");
            if (Adapter.CustomerTypeUpdate(customer_type,customer_type_num) < 1)
                throw new Exception("Customer Type was no updated");
        }

        public bool CustomerTypeExist(string customer_type)
        {
            if (customer_type == null)
                throw new Exception("Customer Type is missing");
            if ((int)(Adapter.CustomerTypeExists(customer_type)) < 1) return false;
            return true;

        }

        public CustomerTypeDS.customer_type_tableDataTable CustomerTypeGetByName(string customer_type)
        {
            if (customer_type == null)
                throw new Exception("Customer Type is missing");
            return Adapter.CustomerTypeGetByName(customer_type);
        }
    
    }
}
